package com.zhijian.medical.controller;

import com.zhijian.medical.annotation.Response;
import com.zhijian.medical.entity.po.BeforeDehydration;
import com.zhijian.medical.entity.vo.request.BeforeDyeInsideSaveOrUpdateVo;
import com.zhijian.medical.entity.vo.request.BeforeDyeSaveOrUpdateVo;
import com.zhijian.medical.entity.vo.request.BeforeDyeSearchVo;
import com.zhijian.medical.entity.vo.response.BeforeDyeListVo;
import com.zhijian.medical.entity.vo.response.BeforeDyeVo;
import com.zhijian.medical.service.BeforeDyeService;
import com.zhijian.medical.util.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 染色前的样本放置容器表
 *
 * @author HCG
 * @version 1.0
 * @date 2022-11-08 16:27:02
 */
@Slf4j
@Controller
@Api(tags = "染色前的样本放置容器表")
public class BeforeDyeController {

    @Autowired
    private BeforeDyeService service;

    /**
     * 新增
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/before/dye")
    @ApiOperation("新增")
    public boolean insert(@RequestBody BeforeDyeSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return service.save(param);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Response
    @DeleteMapping("/before/dye/{id}")
    @ApiOperation("删除")
    public boolean delete(@PathVariable("id") Long id) {
        log.info("{} - {}| delete info", this.getClass().getSimpleName(), id);
        service.deleteById(id);
        return true;
    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Response
    @GetMapping("/before/dye/{id}")
    @ApiOperation("根据id查询")
    public BeforeDyeVo selectById(@PathVariable("id") Long id) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), id);
        return service.selectVoById(id);
    }

    /**
     * 分页查询
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/before/dye/page")
    @ApiOperation("分页查询")
    public Page<BeforeDyeListVo> selectByCondition(@RequestBody(required = false) BeforeDyeSearchVo param) {
        if (param == null)
            param = BeforeDyeSearchVo.builder().build();
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
        return service.selectPage(param);
    }

    /**
     * 详情里面的保存
     *
     * @param param
     * @return
     */
    @Response
    @PutMapping("/before/dye/inside/{id}")
    @ApiOperation("详情里面的保存")
    public boolean insideSave(@PathVariable("id") Long id, @RequestBody BeforeDyeInsideSaveOrUpdateVo param) {
        param.setId(id);
        return service.insideSave(param);
    }

}